/*
 * @(#)WorkflowDocThroughUserRecord.java
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */
package com.dcivision.workflow.bean;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * WorkflowDocThroughUserRecord.java
 * 
 * This class is the serializable bean reflecting business logic uses.
 * 
 * @author Lun Au
 * @company DCIVision Limited
 * @creation date 26/11/2004
 * @version $Revision: 1.5 $
 */
public class WorkflowDocThroughUserRecord extends WorkflowProgress {
  
  public static final String REVISION = "$Revision: 1.5 $";
  static final long serialVersionUID = 3034010461951239023L;
  
  protected Log log = LogFactory.getLog(this.getClass().getName());
  
  // Document profile, document no, document title
  // specified for the document pass through user report
  private Integer workflowProgressID = null;
  private List documentProfileInfo = null;
  private Object relatedObject = null;
  private String documentProfileName = null;
  private List responsibleList = null;
  
  // Together with the inherited userDef1-5,
  // These user defined fields here is used for DmsDocument
  private String userDef6 = null;
  private String userDef7 = null;
  private String userDef8 = null;
  private String userDef9 = null;
  private String userDef10 = null;
  
  public WorkflowDocThroughUserRecord() {}
  
  public WorkflowDocThroughUserRecord ( WorkflowProgress workflowProgress ) throws NoSuchMethodException {
    
    Method getters[] = workflowProgress.getClass().getMethods();
    try {
      for ( int i = 0 ; i < getters.length ; i++ ) {
        if ( getters[i].getName().startsWith("get") ) {
          try {
            Method setter = this.getClass().getMethod ( "set"+getters[i].getName().substring(3), new Class[]{getters[i].getReturnType()});
            setter.invoke(this, new Object[]{getters[i].invoke(workflowProgress,null)});
          } catch (NoSuchMethodException nsme) {
            // No corresponding setter method, no big deal
          }
        }
      }
    } catch (IllegalAccessException iae) {
      log.error("Illegal Access", iae);
    } catch (java.lang.reflect.InvocationTargetException ite) {
      log.error("Invocation Error", ite );
    }
  }
  /**
   * @param workflowProgressID The workflowProgressID to set.
   */
  public void setWorkflowProgressID ( Integer workflowProgressID ) {
    this.workflowProgressID = workflowProgressID;
  }
  /**
   * @return Returns the workflowProgressID.
   */
  public Integer getWorkflowProgressID () {
    return this.workflowProgressID;
  }
  /**
   * @param documentProfileInfo The documentProfileInfo to set.
   */
  public void setDocumentProfileInfo (List documentProfileInfo ) {
    this.documentProfileInfo = documentProfileInfo;
  }
  /**
   * @return Returns the documentProfileInfo.
   */
  public List getDocumentProfileInfo() {
    return this.documentProfileInfo;
  }
  /**
   * @param relatedObject The relatedObject to set.
   */
  public void setRelatedObject(Object relatedObject) {
    this.relatedObject = relatedObject;
  }
  /**
   * @return Returns the relatedObject.
   */
  public Object getRelatedObject(){
    return this.relatedObject;
  }
  /**
   * @param documentProfileName The documentProfileName to set.
   */
  public void setDocumentProfileName(String documentProfileName) {
    this.documentProfileName = documentProfileName;
  }
  /**
   * @return Returns the documentProfileName.
   */
  public String getDocumentProfileName() {
    return this.documentProfileName;
  }
  /**
   * @return Returns the responsibleList.
   */
  public List getResponsibleList ( String targetType, String targetID ) {
    if ( responsibleList==null ) {
      responsibleList = new ArrayList();
    }
    return this.responsibleList;
  }
  
  public void addResponsible ( String targetType, String targetID ) {
    if ( responsibleList==null ) {
      responsibleList = new ArrayList();
    }
    this.responsibleList.add ( new String[] { targetType, targetID } );
  }
  /**
   * @return Returns the userDef6.
   */
  public String getUserDef6() {
    return(this.userDef6);
  }
  /**
   * @param userDef6 The userDef6 to set.
   */
  public void setUserDef6(String userDef6) {
    this.userDef6 = userDef6;
  }
  /**
   * @return Returns the userDef7.
   */
  public String getUserDef7() {
    return(this.userDef7);
  }
  /**
   * @param userDef7 The actionClasuserDef7sName to set.
   */
  public void setUserDef7(String userDef7) {
    this.userDef7 = userDef7;
  }
  /**
   * @return Returns the userDef8.
   */
  public String getUserDef8() {
    return(this.userDef8);
  }
  /**
   * @param userDef8 The userDef8 to set.
   */
  public void setUserDef8(String userDef8) {
    this.userDef8 = userDef8;
  }
  /**
   * @return Returns the userDef9.
   */
  public String getUserDef9() {
    return(this.userDef9);
  }
  /**
   * @param userDef9 The userDef9 to set.
   */
  public void setUserDef9(String userDef9) {
    this.userDef9 = userDef9;
  }
  /**
   * @return Returns the userDef10.
   */
  public String getUserDef10() {
    return(this.userDef10);
  }
  /**
   * @param userDef10 The userDef10 to set.
   */
  public void setUserDef10(String userDef10) {
    this.userDef10 = userDef10;
  }
  
}
